<?php
	require_once dirname(BASEPATH) . "/application/controllers/system/_init.php";
	
	abstract class abs_index extends _init
	{
		function index(){			
			$this->set_header_main();
			$this->set_navigation(array('<i class="icon-home"></i> หน้าแรก' => base_url()));
					
			$display_length = 6;
			$this->load->model('local/data/article/mod_article');					
			$this->load->model('local/data/etc/mod_carousel');
			$this->load->model('local/data/etc/mod_banner');
			$this->load->library('define/general_define');
			
			$data_content_1['carousel_list'] = $this->mod_carousel->get_usable_carousel();
			$data_content_2['data'] = $this->mod_article->get_article_list($display_length);
			$data_content_2['page_count'] = $this->mod_article->get_count() / $display_length;
			
			$data_content_5['data'] = $this->mod_banner->get_banner_homepage_zone();					
			$data_content_6['data'] = $this->mod_article->get_feature_article($this->general_define->feature_article_length);
			
			$this->template->write('carousel', $this->load->view('home/frm_carousel', $data_content_1, true));
			$this->template->write('content_1', $this->load->view('home/frm_article', $data_content_2, true));						
			$this->template->write('right_sidebar', $this->load->view('widget/main/frm_banner_vertical', $data_content_5, true));
			$this->template->write('right_sidebar', $this->load->view('widget/main/frm_feature_article', $data_content_6, true));
			$this->template->write('right_sidebar', $this->load->view('widget/main/frm_facebook_likebox', null, true));		
			$this->template->render();			
		}
		function page(){
			$this->set_header_main();
			$this->set_navigation(array('<i class="icon-home"></i> หน้าแรก' => base_url()));
					
			$this->load->model('local/data/article/mod_article');					
			$this->load->model('local/data/etc/mod_carousel');
			$this->load->model('local/data/etc/mod_banner');
			
			$page = $this->input->get('p');
			$display_length = 6;
			if (!empty($page)) {
				$start_index = ($page-1) * $display_length;
				if ($start_index < 0)
					$start_index = 0;
			} else	
				$start_index = 0;
			
			$data_content_1['carousel_list'] = $this->mod_carousel->get_carousel_list();					
			$data_content_2['data'] = $this->mod_article->get_article_list($display_length, $start_index);
			$data_content_2['page_count'] = $this->mod_article->get_count() / $display_length;		
					
			/*$this->load->model('local/data/cafe/mod_cafe');
			$data_content_4['data'] = $this->mod_cafe->get_shuffle_cafe($this->amount_shuffle_cafe);*/
						
			$data_content_5['data'] = $this->mod_banner->get_banner_homepage_zone();				
			$data_content_6['data'] = $this->mod_article->get_feature_article(5);
			
			$this->template->write('carousel', $this->load->view('home/frm_carousel', $data_content_1, true));
			$this->template->write('content_1', $this->load->view('home/frm_article', $data_content_2, true));			
			//$this->template->write('right_sidebar', $this->load->view('widget/main/frm_cafe', $data_content_4, true));			
			$this->template->write('right_sidebar', $this->load->view('widget/main/frm_banner_vertical', $data_content_5, true));
			$this->template->write('right_sidebar', $this->load->view('widget/main/frm_feature_article', $data_content_6, true));		
			$this->template->render();	
		}
	}
?>